package com.xkdx.caipiao.pay;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.xkdx.caipiao.LotteryHallActivity;
import com.xkdx.caipiao.MainTabActivity;
import com.xkdx.caipiao.R;
import com.xkdx.caipiao.RechargeActivity;

public class PayActivity extends Activity {
	ImageView im;
	TextView tv, tv_failed;
	Button btn1, btn2;
	int tag;
	String money ="";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pay_order_caipiao);
		tag = getIntent().getIntExtra("tag", 2);
		money = getIntent().getStringExtra("money");
		init();
	}

	private void init() {
		im = (ImageView) findViewById(R.id.im);
		tv = (TextView) findViewById(R.id.tv);
		btn1 = (Button) findViewById(R.id.look_order);
		btn2 = (Button) findViewById(R.id.continue_buy);
		tv_failed = (TextView) findViewById(R.id.tv_failed);
		btn2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent(PayActivity.this,
						MainTabActivity.class);
				startActivity(intent);
			}
		});

		switch (tag) {
		case 1:
			btn1.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {

					Intent intent = new Intent(PayActivity.this,
							MainTabActivity.class);
					intent.putExtra("tag", "order");
					startActivity(intent);
				}
			});
			break;
		case 2:
			im.setImageResource(R.drawable.pay_faile_im_caipiao);
			tv.setText(getResources().getString(R.string.pay_faile));
			tv_failed.setVisibility(View.VISIBLE);
			btn1.setText(getResources().getString(R.string.chongzhi));
			btn1.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					Intent intent1 = new Intent(PayActivity.this,
							RechargeActivity.class);
					intent1.putExtra("money", money);
					startActivity(intent1);
					finish();

				}
			});

			break;

		default:
			break;
		}

	}

	public void onBackClick(View view) {
		finish();
		Intent intent = new Intent(this, MainTabActivity.class);
		startActivity(intent);
	}
}
